import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:sptapp/api/interface/home_api.dart';
import 'package:sptapp/api/request/response_data.dart';
import 'package:sptapp/config/const.dart';
import 'package:sptapp/moudle/common_info.dart';
import 'package:sptapp/moudle/level_picker/level_picker.dart';
import 'package:sptapp/moudle/refresh/my_refresh.dart';
import 'package:sptapp/page/monitor/device_control_input.dart';
import 'package:sptapp/page/monitor/device_control_select.dart';

import '../../moudle/message.dart';
import '../../widget/common_widget.dart';

const String TSL = 'TSL';
const String TEL = 'TEL';

const String TS1 = 'TS1';
const String TE1 = 'TE1';
const String TS2 = 'TS2';
const String TE2 = 'TE2';

const String BVF = 'BVF';
const String BVM = 'BVM';

const String BVU = 'BVU';
const String BUB = 'BUB';
const String BRC = 'BRC';
const String BRD = 'BRD';



class DeviceControl extends StatefulWidget {
  final Map? arguments;
  const DeviceControl({super.key, this.arguments});

  @override
  State<DeviceControl> createState() => _DeviceControlState();
}

class _DeviceControlState extends State<DeviceControl> {

  List newSetings = [];

  Map cusCodesValues = {};

  String YMD = '';
  String HM = '';

  Map bsoc1 = {};
  Map bsoc2 = {};
  Map bsocg1 = {};
  Map bsocg2 = {};

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _getDeviceDats();
  }

  _getDeviceDats()async{
    if(baseDeviceNum != null && baseDeviceNum != ''){
      Map<String,dynamic> query = {
        'sn':baseDeviceNum
      };
      ResponseData res = await HomeAPI.getDevParameter(query);
      if(res.code == 200){
        newSetings.clear();
        List arr = res.data ??[];
        for (var item in arr) {
          item['isShow'] = true;
          newSetings.add(item);
        }

        if(newSetings.isNotEmpty){
          newSetings[0]['isShow'] = true;
          for (var map in newSetings) {
            List arr = map['items'] ?? [];
            for(var itemMap in arr){
              if(itemMap['code'] == 'T'){
                itemMap['value'] = _changeTimeYMDStr(itemMap['value']);
              }else if(itemMap['code'] == 'F1'){
                itemMap['value'] = _changeTimeHMStr(itemMap['value']);
              }else if(itemMap['code'] == 'BSOC1'){
                bsoc1 = itemMap;
              }else if(itemMap['code'] == 'BSOC2'){
                bsoc2 = itemMap;
              }else if(itemMap['code'] == 'BSOCG1'){
                bsocg1 = itemMap;
              }else if(itemMap['code'] == 'BSOCG2'){
                bsocg2 = itemMap;
              }
              cusCodesValues[itemMap['code']] = itemMap['value'] ?? '0';
            }
          }
        }
      }
      if(mounted){setState(() {});}
    }
  }

  _changeTimeYMDStr(String val){
    if(val != null && val.isNotEmpty && val.length == 14){
      String res;
      String month = val.substring(4,6);
      if(month == '01'){
        month = 'Jan';
      }else if(month == '02'){
        month = 'Feb';
      }else if(month == '03'){
        month = 'Mar';
      }else if(month == '04'){
        month = 'Apr';
      }else if(month == '05'){
        month = 'May';
      }else if(month == '06'){
        month = 'Jun';
      }else if(month == '07'){
        month = 'Jul';
      }else if(month == '08'){
        month = 'Aug';
      }else if(month == '09'){
        month = 'Sep';
      }else if(month == '10'){
        month = 'Oct';
      }else if(month == '11'){
        month = 'Nov';
      }else if(month == '12'){
        month = 'Dec';
      }

      res = '$month/${val.substring(6,8)}/${val.substring(0,4)}';
      YMD = '${val.substring(2,4)}${val.substring(4,6)}${val.substring(6,8)}';
     return res;
    }
    return val;
  }
  _changeTimeHMStr(String val){
    if(val != null && val.isNotEmpty && val.length == 14){
      String res;
      res = '${val.substring(8,10)}:${val.substring(10,12)}';
      HM = '${val.substring(8,10)}${val.substring(10,12)}';
      return res;
    }
    return val;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: defaultBlackBgColor,
      body: Container(
        color: Colors.transparent,
        padding: EdgeInsets.symmetric(horizontal: 30.w),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            SizedBox(height: ScreenUtil().statusBarHeight + 40.w,),
            myCustomCenterTitleAppBar('Settings'.tr),
            SizedBox(height: 40.w,),
            Expanded(child: Container(
              child: EasyRefresh(
                header: myRefreshHeader(),
                onRefresh: ()async{
                  _getDeviceDats();
                },
                child: ListView.builder(itemBuilder: (context,index){
                  Map setItem = newSetings[index];
                  List items = setItem['items'] ?? [];
                  bool show = setItem['show'] ?? false;
                  if(!show){
                    return Container();
                  }
                  return Container(
                    margin: EdgeInsets.only(bottom: 20),
                    child: Column(
                      children: [
                        Container(
                          decoration: BoxDecoration(
                              color: Color.fromRGBO(255, 255, 255, 0.1),
                              borderRadius: BorderRadius.circular(32.w)
                          ),
                          padding: EdgeInsets.symmetric(horizontal: 40.w),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Container(
                                height: 120.w,
                                child: Column(
                                  children: [
                                    Expanded(child: GestureDetector(
                                      onTap: (){
                                        // setState(() {
                                        //   setItem['isShow'] = !setItem['isShow'];
                                        // });
                                      },
                                      child: Row(
                                        children: [
                                          Expanded(child: Text(setItem['name']??'',style: TextStyle(
                                              fontWeight: FontWeight.w600,
                                              color: Colors.white,
                                              fontSize:36.sp
                                          ),),),
                                          // GestureDetector(
                                          //   child: Icon(setItem['isShow']?Icons.arrow_drop_up:Icons.arrow_drop_down,color: Color(0xff999999),size: 46.w,),
                                          // )
                                        ],
                                      ),
                                    )),
                                    // SizedBox(height: 34.w,),
                                    Container(
                                      height: 1.w,
                                      color: Color(0x2fEEEEEE),
                                    )
                                  ],
                                ),
                              ),
                              // SizedBox(height: 32.w,),
                              ListView.builder(itemBuilder: (context,index){
                                Map item = items[index];
                                bool show = item['show'] ?? false;
                                bool available = item['available'] ?? true;
                                if(item['type'] == null || show == false){
                                  return Container();
                                }
                                if(item['type'].toString() == '0'){
                                  return Opacity(opacity: available?1:0.5,child: Container(
                                    color: Colors.transparent,
                                    child: Column(
                                      children: [
                                        Container(
                                          padding: EdgeInsets.symmetric(vertical: 34.w),
                                          child: Container(
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color:  Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),visible: item['subTitle']!=null&& item['subTitle'].toString().isNotEmpty,)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                GestureDetector(
                                                  onTap: ()async{
                                                    if(!available){
                                                      return;
                                                    }
                                                    setState(() {
                                                      if(item['value'].toString() == '1'){
                                                        item['value'] = '0';
                                                      }else{
                                                        item['value'] = '1';
                                                      }
                                                    });
                                                    Map<String,dynamic> data = {
                                                      'sn': baseDeviceNum??'',
                                                      'value': item['value'],
                                                      'code':item['code']
                                                    };
                                                    ResponseData result = await HomeAPI.postDevParameter(data);
                                                    if(result.code == 200){
                                                    }
                                                  },
                                                  child: Container(
                                                      width: 92.w,
                                                      height: 48.w,
                                                      alignment: Alignment.centerRight,
                                                      child:
                                                      Image.asset(item['value'].toString() == '1'?'assets/common/switch_btn_open.png': 'assets/common/switch_btn_close.png',width: 92.w,)
                                                    //                   FlutterSwitch(
                                                    //
                                                    //                     activeColor: themeColor,
                                                    //                     value: item['value'].toString() == '1',
                                                    //                     onToggle: (val)async{
                                                    //                       setState(() {
                                                    //                         if(val){
                                                    //                           item['value'] = '1';
                                                    //                         }else{
                                                    //                           item['value'] = '0';
                                                    //                         }
                                                    //                       });
                                                    //                       Map<String,dynamic> data = {
                                                    //                         'sn': baseDeviceNum??'',
                                                    //                         'value': val?'1':'0',
                                                    //                         'code':item['code']
                                                    //                       };
                                                    //                       ResponseData result = await HomeAPI.postDevParameter(data);
                                                    //                       if(result.code == 200){
                                                    //                         setState(() {
                                                    //                           if(val){
                                                    //                             item['value'] = '1';
                                                    //                           }else{
                                                    //                             item['value'] = '0';
                                                    //                           }
                                                    //                         });
                                                    //                       }
                                                    //                     },
                                                    //                   ),
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                        ),
                                        Container(
                                          height: 1.w,
                                          color: Color.fromRGBO(255, 255, 255, 0.1),
                                        )
                                      ],
                                    ),
                                  ),);
                                }
                                else if(item['type'].toString() == '1'){
                                  return Opacity(opacity: available ? 1 : 0.5,child: GestureDetector(
                                    onTap: (){
                                      if(!available){
                                        return;
                                      }
                                      showModalBottomSheet(context: context, builder: (ctx){
                                        return DeviceControlSelect(item: item,callBack: (res)async{
                                          setState(() {
                                            item['value'] = res['name'];
                                          });
                                        },);
                                      },isScrollControlled: true);
                                    },
                                    child: Container(
                                      color: Colors.transparent,
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            padding: EdgeInsets.symmetric(vertical: 34.w),
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color: Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),visible: item['subTitle']!=null&& item['subTitle'].toString().isNotEmpty,)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                Container(
                                                  constraints: BoxConstraints(
                                                    maxWidth: 230.w,
                                                  ),
                                                  child: Text('${item['value']??''}',style: TextStyle(
                                                      fontWeight: FontWeight.w400,
                                                      color: Colors.white,
                                                      fontSize: 28.sp
                                                  ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                ),
                                                Image.asset('assets/common/control_right.png',width: 48.w,)
                                              ],
                                            ),
                                          ),
                                          Container(
                                            height: 1.w,
                                            color: Color.fromRGBO(255, 255, 255, 0.1),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),);
                                }
                                else if(item['type'].toString() == '3'){
                                  return Opacity(opacity: available?1:0.5,child: GestureDetector(
                                    onTap: (){
                                      if(!available){
                                        return;
                                      }
                                      JhPickerTool.showArrayPicker(context,
                                          data: [
                                            ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17',
                                              '18','19','20','21','22','23'],
                                            ['00']
                                          ],
                                          clickCallBack: (selecteds,strDatas)async{
                                            setState(() {
                                              item['value'] = strDatas[0];
                                              cusCodesValues[item['code']] = item['value'];
                                            });
                                            if(item['code'] == TSL){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '${_changeTime(strDatas[0])},${_changeTime(cusCodesValues[TEL])}',
                                                'code':'TSL'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = strDatas[0];
                                                });
                                              }
                                            }
                                            else if(item['code'] == TEL){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '${_changeTime(cusCodesValues[TSL])},${_changeTime(strDatas[0])}',
                                                'code':'TSL'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = strDatas[0];
                                                });
                                              }
                                            }
                                            else if(item['code'] == TS1){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '${_changeTime(strDatas[0])},${_changeTime(cusCodesValues[TE1])},${_changeTime(cusCodesValues[TS2])},${_changeTime(cusCodesValues[TE2])}',
                                                'code':'TS1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = strDatas[0];
                                                });
                                              }
                                            }
                                            else if(item['code'] == TE1){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '${_changeTime(cusCodesValues[TS1])},${_changeTime(strDatas[0])},${_changeTime(cusCodesValues[TS2])},${_changeTime(cusCodesValues[TE2])}',
                                                'code':'TS1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = strDatas[0];
                                                });
                                              }
                                            }
                                            else if(item['code'] == TS2){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '${_changeTime(cusCodesValues[TS1])},${_changeTime(cusCodesValues[TE1])},${_changeTime(strDatas[0])},${_changeTime(cusCodesValues[TE2])}',
                                                'code':'TS1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = strDatas[0];
                                                });
                                              }
                                            }
                                            else if(item['code'] == TE2){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '${_changeTime(cusCodesValues[TS1])},${_changeTime(cusCodesValues[TE1])},${_changeTime(cusCodesValues[TS2])},${_changeTime(strDatas[0])}',
                                                'code':'TS1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = strDatas[0];
                                                });
                                              }
                                            }
                                          },
                                          title: item['name'],
                                          subTitle: item['subTitle'],
                                          desc: item['desc'],
                                          normalIndex: [int.parse(item['value']??'0'),0]);
                                    },
                                    child: Container(
                                      color: Colors.transparent,
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            padding: EdgeInsets.symmetric(vertical: 34.w),
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color: Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),visible: item['subTitle']!=null&& item['subTitle'].toString().isNotEmpty,)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                Container(
                                                  constraints: BoxConstraints(
                                                      maxWidth: 230.w
                                                  ),
                                                  child: Text('${(int.parse((item['value']??'0').toString())<10?'0${int.parse((item['value']??'0').toString())}':item['value']??'')}:00',style: TextStyle(
                                                      fontWeight: FontWeight.w400,
                                                      color: Colors.white,
                                                      fontSize: 28.sp
                                                  ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                ),
                                                Image.asset('assets/common/control_right.png',width: 48.w,)
                                              ],
                                            ),
                                          ),
                                          // SizedBox(height: 32.w,),
                                          Container(
                                            height: 1.w,
                                            color: Color.fromRGBO(255, 255, 255, 0.1),
                                          )
                                        ],
                                      ),
                                    ),
                                  ));
                                }
                                else if(item['type'].toString() == '2'){
                                  return Opacity(opacity: available?1:0.5,child: GestureDetector(
                                    onTap: (){
                                      if(!available){
                                        return;
                                      }
                                      SmartDialog.show(builder: (ctx){
                                        return DeviceControlInput(item: item,callBack: (val){
                                          setState(() {
                                            item['value'] = val;
                                          });
                                        },);
                                      },alignment: Alignment.center,clickMaskDismiss: false);
                                    },
                                    child: Container(
                                      color: Colors.transparent,
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            padding: EdgeInsets.symmetric(vertical: 34.w),
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              mainAxisAlignment: MainAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color: Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),visible: item['subTitle']!=null&& item['subTitle'].toString().isNotEmpty,)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                Container(
                                                  constraints: BoxConstraints(
                                                      maxWidth: 230.w
                                                  ),
                                                  child: Text('${item['value']??''}',style: TextStyle(
                                                      fontWeight: FontWeight.w400,
                                                      color: Colors.white,
                                                      fontSize: 28.sp
                                                  ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                ),
                                                Image.asset('assets/common/control_right.png',width: 48.w,)
                                              ],
                                            ),

                                          ),
                                          // SizedBox(height: 32.w,),
                                          Container(
                                            height: 1.w,
                                            color: Color(0x2fEEEEEE),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),);
                                }
                                else if(item['type'].toString() == '4'){
                                  return Opacity(opacity: available?1:0.5,child: GestureDetector(
                                    onTap: (){
                                      if(!available){
                                        return;
                                      }
                                      String code = item['code'];
                                      if(code == 'T'){
                                        JhPickerTool.showDatePicker(context,
                                          dateType: DateType.YMD,
                                          value: DateTime.now(),
                                          clickCallback: (val,value)async{
                                            print('val === '+val);
                                            Map<String,dynamic> data = {
                                              'sn': baseDeviceNum??'',
                                              'value': '$val$HM',
                                              'code': 'T'
                                            };
                                            setState(() {
                                              YMD = val;
                                              item['value'] = value;
                                            });
                                            ResponseData result = await HomeAPI.postDevParameter(data);
                                            if(result.code == 200){
                                              setState(() {
                                                YMD = val;
                                                item['value'] = value;
                                              });
                                            }
                                          },
                                          title: item['name'],
                                          subTitle: item['subTitle'],
                                          desc: item['desc'],
                                        );
                                      }
                                      else if(code == 'F1'){
                                        JhPickerTool.showDatePicker(context,
                                          dateType: DateType.HM,
                                          value: DateTime.now(),
                                          clickCallback: (val,value)async{
                                            print('val === '+val);
                                            Map<String,dynamic> data = {
                                              'sn': baseDeviceNum??'',
                                              'value': '$YMD$val',
                                              'code': 'T'
                                            };
                                            setState(() {
                                              HM = val;
                                              item['value'] = value;
                                            });
                                            ResponseData result = await HomeAPI.postDevParameter(data);
                                            if(result.code == 200){
                                              setState(() {
                                                HM = val;
                                                item['value'] = value;
                                              });
                                            }
                                          },
                                          title: item['name'],
                                          subTitle: item['subTitle'],
                                          desc: item['desc'],
                                        );
                                      }
                                    },
                                    child: Container(
                                      color: Colors.transparent,
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            padding: EdgeInsets.symmetric(vertical: 34.w),
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              mainAxisAlignment: MainAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color: Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),visible: item['subTitle']!=null&& item['subTitle'].toString().isNotEmpty,)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                Container(
                                                  constraints: BoxConstraints(
                                                      maxWidth: 230.w
                                                  ),
                                                  child: Text('${item['value']??''}',style: TextStyle(
                                                      fontWeight: FontWeight.w400,
                                                      color: Colors.white,
                                                      fontSize: 28.sp
                                                  ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                ),
                                                Image.asset('assets/common/control_right.png',width: 48.w,)
                                              ],
                                            ),
                                          ),
                                          // SizedBox(height: 32.w,),
                                          Container(
                                            height: 1.w,
                                            color: Color.fromRGBO(255, 255, 255, 0.1),
                                          )
                                        ],
                                      ),
                                    ),
                                  ));
                                }
                                else if(item['type'].toString() == '5'){
                                  return Opacity(opacity: available?1.0:0.5,child: GestureDetector(
                                    onTap: ()async{
                                      if(!available){
                                        return;
                                      }
                                      String content = '';
                                      if(item['code'].toString() == 'OTA'){
                                        content = 'The current version is v${item['value'].toString().replaceAll(" ", "")} You can upgrade to the lastest version to access more features';
                                      }
                                      else if(item['code'].toString() == 'OTA9'){
                                        content = 'You are already have the latest version!';
                                      }
                                      SmartDialog.show(builder: (ctx){
                                        return Container(
                                          width: 600.w,
                                          padding: EdgeInsets.all(32.w),
                                          decoration: BoxDecoration(
                                              color: Color(0xff1E1D20),
                                              borderRadius: BorderRadius.circular(24.w)
                                          ),
                                          child: Column(
                                            mainAxisSize: MainAxisSize.min,
                                            children: [
                                              Container(
                                                child: Row(
                                                  children: [
                                                    Expanded(child: Text(item['name']??'',style: TextStyle(
                                                        color: Colors.white,
                                                        fontSize: 32.sp,
                                                        fontWeight: FontWeight.w400
                                                    ),textAlign: TextAlign.center,)),
                                                  ],
                                                ),
                                              ),
                                              Container(
                                                height: 1.w,
                                                color: Color.fromRGBO(255, 255, 255, 0.1),
                                                margin: EdgeInsets.symmetric(vertical: 32.w),
                                              ),
                                              Container(
                                                alignment: Alignment.center,
                                                child: Row(
                                                  mainAxisAlignment: MainAxisAlignment.center,
                                                  children: [
                                                    Expanded(child: Text(content,style: TextStyle(
                                                        color: Colors.white,
                                                        fontSize: 32.sp,
                                                        fontWeight: FontWeight.w400
                                                    ),textAlign: TextAlign.center,))
                                                  ],
                                                ),
                                              ),
                                              SizedBox(height: 64.w,),
                                              Container(
                                                child: Row(
                                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                                  children: [
                                                    GestureDetector(
                                                      onTap: (){
                                                        SmartDialog.dismiss();
                                                      },
                                                      child: Container(
                                                        decoration: BoxDecoration(
                                                            color: Color.fromRGBO(255, 255, 255, 0.1),
                                                            borderRadius: BorderRadius.circular(8.w)
                                                        ),
                                                        width: 252.w,
                                                        height: 108.w,
                                                        alignment: Alignment.center,
                                                        child: Text('Continue'.tr,style: TextStyle(
                                                            color: Colors.white,
                                                            fontSize: 32.sp,
                                                            fontWeight: FontWeight.w600
                                                        ),),
                                                      ),
                                                    ),
                                                    GestureDetector(
                                                      onTap: ()async{
                                                        String value = item['value'] ?? '';
                                                        String code = item['code'] ?? '';
                                                        if(item['code'].toString() == 'OTA'){
                                                          value = '0';
                                                          code = 'OTA';
                                                        }else if(item['code'].toString() == 'OTA9'){
                                                          value = '9';
                                                          code = 'OTA';
                                                        }
                                                        Map<String,dynamic> data = {
                                                          'sn': baseDeviceNum??'',
                                                          'value': value,
                                                          'code':code
                                                        };
                                                        ResponseData res = await HomeAPI.postDevParameter(data);
                                                        if(res.code == 200){
                                                          SmartDialog.dismiss();
                                                          showToast('Success');
                                                        }
                                                      },
                                                      child: Container(
                                                        decoration: BoxDecoration(
                                                            color: Color(0xff3C55F8),
                                                            borderRadius: BorderRadius.circular(8.w)
                                                        ),
                                                        width: 252.w,
                                                        height: 108.w,
                                                        alignment: Alignment.center,
                                                        child: Text('Update'.tr,style: TextStyle(
                                                            color: Colors.white,
                                                            fontSize: 32.sp,
                                                            fontWeight: FontWeight.w600
                                                        ),),
                                                      ),
                                                    )
                                                  ],
                                                ),
                                              )
                                            ],
                                          ),
                                        );
                                      },alignment: Alignment.center,maskColor: Color.fromRGBO(0, 0, 0, 0.2));
                                    },
                                    child: Container(
                                      color: Colors.transparent,
                                      // margin: EdgeInsets.only(bottom: 32.w),
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            padding: EdgeInsets.symmetric(vertical: 34.w),
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color: Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(visible: item['subTitle']!=null&& item['subTitle'].toString().isNotEmpty,child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                Container(
                                                  constraints: BoxConstraints(
                                                      maxWidth: 240.w
                                                  ),
                                                  child: Text(item['value']??'',style: TextStyle(
                                                      fontWeight: FontWeight.w400,
                                                      color: Colors.white,
                                                      fontSize: 28.sp
                                                  ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                ),
                                                Image.asset('assets/common/control_right.png',width: 48.w,)
                                              ],
                                            ),
                                          ),
                                          // SizedBox(height: 32.w,),
                                          Container(
                                            height: 1.w,
                                            color: Color.fromRGBO(255, 255, 255, 0.1),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),);
                                }
                                else if(item['type'].toString() == '6'){
                                  return Opacity(opacity: available?1:0.5,child: GestureDetector(
                                    onTap: (){
                                      if(!available){
                                        return;
                                      }
                                      List options = [];
                                      List values = [];
                                      List arr = item['options'] ?? [];
                                      for (var item in arr) {
                                        if(item is Map){
                                          Map map = item;
                                          map.forEach((key,value){
                                            if(key.toString() != 'desc'){
                                              options.add(key);
                                              values.add(value);
                                            }
                                          });
                                        }
                                      }
                                      int selxIndex = 0;
                                      for(int i = 0;i<options.length;i++){
                                        if(item['value'] == options[i]){
                                          selxIndex = i;
                                        }
                                      }
                                      JhPickerTool.showStringPicker(context,
                                          data: options,
                                          clickCallBack: (index,val)async {
                                            print('index ===$index val == ${values[index]}');



                                            if(item['code'].toString() == 'BSOC1'){

                                              List arr2 = bsoc2['options'] ?? [];
                                              String bs2 = '';
                                              for (var item in arr2) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsoc2['value']){
                                                      bs2 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr3 = bsocg1['options'] ?? [];
                                              String bsg1 = '';
                                              for (var item in arr3) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsocg1['value']){
                                                      bsg1 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr4 = bsocg2['options'] ?? [];
                                              String bsg2 = '';
                                              for (var item in arr4) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsocg2['value']){
                                                      bsg2 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              setState(() {
                                                item['value'] = options[index];
                                                bsoc1['value'] = item['value'];
                                              });
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '${values[index]},$bs2,$bsg1,$bsg2',
                                                'code': 'BSOC1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){ }

                                            }
                                            else if(item['code'].toString() == 'BSOC2'){
                                              List arr1 = bsoc1['options'] ?? [];
                                              String bs1 = '';
                                              for (var item in arr1) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsoc1['value']){
                                                      bs1 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr3 = bsocg1['options'] ?? [];
                                              String bsg1 = '';
                                              for (var item in arr3) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsocg1['value']){
                                                      bsg1 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr4 = bsocg2['options'] ?? [];
                                              String bsg2 = '';
                                              for (var item in arr4) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsocg2['value']){
                                                      bsg2 = value;
                                                    }
                                                  });
                                                }
                                              }

                                              setState(() {
                                                item['value'] = options[index];
                                                bsoc2['value'] = item['value'];
                                              });
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '$bs1,${values[index]},$bsg1,$bsg2',
                                                'code': 'BSOC1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){ }

                                            }
                                            else if(item['code'].toString() == 'BSOCG1'){

                                              List arr1 = bsoc1['options'] ?? [];
                                              String bs1 = '';
                                              for (var item in arr1) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsoc1['value']){
                                                      bs1 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr2 = bsoc2['options'] ?? [];
                                              String bs2 = '';
                                              for (var item in arr2) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsoc2['value']){
                                                      bs2 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr4 = bsocg2['options'] ?? [];
                                              String bsg2 = '';
                                              for (var item in arr4) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsocg2['value']){
                                                      bsg2 = value;
                                                    }
                                                  });
                                                }
                                              }

                                              setState(() {
                                                item['value'] = options[index];
                                                bsocg1['value'] = item['value'];
                                              });
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '$bs1,$bs2,${values[index]},$bsg2',
                                                'code': 'BSOC1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){ }

                                            }else if(item['code'].toString() == 'BSOCG2'){

                                              List arr1 = bsoc1['options'] ?? [];
                                              String bs1 = '';
                                              for (var item in arr1) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsoc1['value']){
                                                      bs1 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr2 = bsoc2['options'] ?? [];
                                              String bs2 = '';
                                              for (var item in arr2) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsoc2['value']){
                                                      bs2 = value;
                                                    }
                                                  });
                                                }
                                              }
                                              List arr4 = bsocg1['options'] ?? [];
                                              String bsg1 = '';
                                              for (var item in arr4) {
                                                if(item is Map){
                                                  Map map = item;
                                                  map.forEach((key,value){
                                                    if(key.toString() == bsocg1['value']){
                                                      bsg1 = value;
                                                    }
                                                  });
                                                }
                                              }

                                              setState(() {
                                                item['value'] = options[index];
                                                bsocg1['value'] = item['value'];
                                              });
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '$bs1,$bs2,$bsg1,${values[index]}',
                                                'code': 'BSOC1'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){ }

                                            }else{
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': values[index],
                                                'code':item['code']
                                              };
                                              setState(() {
                                                item['value'] = options[index];
                                              });
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){ }
                                            }

                                          },
                                          title: item['name'],
                                          subTitle: item['subTitle'],
                                          desc: item['desc'],
                                          normalIndex: selxIndex);
                                    },
                                    child: Container(
                                      color: Colors.transparent,
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            padding: EdgeInsets.symmetric(vertical: 34.w),
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color: Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),visible: item['subTitle']!=null && item['subTitle'].toString().isNotEmpty,)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                Container(
                                                  constraints: BoxConstraints(
                                                    maxWidth: 230.w,
                                                  ),
                                                  child: Text('${item['value']??''}',style: TextStyle(
                                                      fontWeight: FontWeight.w400,
                                                      color: Colors.white,
                                                      fontSize: 28.sp
                                                  ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                ),
                                                Image.asset('assets/common/control_right.png',width: 48.w,)
                                              ],
                                            ),
                                          ),
                                          Container(
                                            height: 1.w,
                                            color: Color.fromRGBO(255, 255, 255, 0.1),
                                          )
                                        ],
                                      ),
                                    ),
                                  ),);
                                }
                                else if(item['type'].toString() == '7'){
                                  String value = item['value']??'';

                                  if((item['code'].toString() == 'BVM' || item['code'].toString() == 'BVF') && value.length>=3){
                                    value = '${value.substring(0,2)}.${value.substring(2,3)}${item['unit']??''}';
                                  }

                                  if((item['code'].toString() == 'BVU' || item['code'].toString() == 'BUB' || item['code'].toString() == 'BRC' || item['code'].toString() == 'BRD') && value.length>=3){
                                    value = '${value.substring(0,2)}.${value.substring(2,3)}${item['unit']??''}';
                                  }

                                  return Opacity(opacity: available?1.0:0.5,child: GestureDetector(
                                    onTap: (){
                                      if(!available){
                                        return;
                                      }
                                      List arr = [];
                                      String fvalue = item['value'].toString().substring(0,2);
                                      String eVlaue = item['value'].toString().substring(2,3);
                                      print('fvalue === $fvalue == e==$eVlaue');
                                      int fIndex = 0;
                                      int index = 0;
                                      for(int i = 42;i<63;i++){
                                        if(fvalue == i.toString()){
                                          fIndex = index;
                                        }
                                        arr.add('$i');
                                        index++;
                                      }

                                      JhPickerTool.showArrayPicker(context,
                                          data: [
                                            arr,
                                            ['0','1','2','3','4','5','6','7','8','9']
                                          ],
                                          tyepe: 1,
                                          clickCallBack: (selecteds,strDatas)async{
                                            print('selecteds ==> $selecteds  strDatas ==> $strDatas');
                                            setState(() {
                                              item['value'] = '${strDatas[0]}${strDatas[1]}';
                                              cusCodesValues[item['code']] = '${strDatas[0]}${strDatas[1]}';
                                            });
                                            if(item['code'] == 'BVM'){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '0${strDatas[0]}${strDatas[1]},0${cusCodesValues['BVF']}',
                                                'code':'BVM'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = '${strDatas[0]}${strDatas[1]}';
                                                });
                                              }
                                            }
                                            else if(item['code'] == 'BVF'){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '0${cusCodesValues['BVM']},0${strDatas[0]}${strDatas[1]}',
                                                'code':'BVM'
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = '${strDatas[0]}${strDatas[1]}';
                                                });
                                              }
                                            }

                                            else if(item['code'] == 'BVU'){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '0${strDatas[0]}${strDatas[1]},0${cusCodesValues['BUB']},0${cusCodesValues['BRC']},0${cusCodesValues['BRD']}',
                                                'code':item['code']
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = '${strDatas[0]}${strDatas[1]}';
                                                });
                                              }
                                            }
                                            else if(item['code'] == 'BUB'){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '0${cusCodesValues['BVU']},0${strDatas[0]}${strDatas[1]},0${cusCodesValues['BRC']},0${cusCodesValues['BRD']}',
                                                'code':item['code']
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = '${strDatas[0]}${strDatas[1]}';
                                                });
                                              }
                                            }
                                            else if(item['code'] == 'BRC'){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '0${cusCodesValues['BVU']},0${cusCodesValues['BUB']},0${strDatas[0]}${strDatas[1]},0${cusCodesValues['BRD']}',
                                                'code':item['code']
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = '${strDatas[0]}${strDatas[1]}';
                                                });
                                              }
                                            }
                                            else if(item['code'] == 'BRD'){
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '0${cusCodesValues['BVU']},0${cusCodesValues['BUB']},0${cusCodesValues['BRC']},0${strDatas[0]}${strDatas[1]}',
                                                'code':item['code']
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = '${strDatas[0]}${strDatas[1]}';
                                                });
                                              }
                                            }

                                            else{
                                              Map<String,dynamic> data = {
                                                'sn': baseDeviceNum??'',
                                                'value': '0${strDatas[0]}${strDatas[1]}',
                                                'code':item['code']
                                              };
                                              ResponseData result = await HomeAPI.postDevParameter(data);
                                              if(result.code == 200){
                                                setState(() {
                                                  item['value'] = '${strDatas[0]}${strDatas[1]}';
                                                });
                                              }
                                            }
                                          },
                                          title: item['name'],
                                          subTitle: item['subTitle'],
                                          desc: item['desc'],
                                          normalIndex: [fIndex,int.parse(eVlaue)]);
                                    },
                                    child: Container(
                                      color: Colors.transparent,
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            padding: EdgeInsets.symmetric(vertical: 34.w),
                                            child: Row(
                                              crossAxisAlignment: CrossAxisAlignment.center,
                                              children: [
                                                Expanded(child: Container(
                                                  child: Column(
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    crossAxisAlignment: CrossAxisAlignment.start,
                                                    children: [
                                                      Text(item['name']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w600,
                                                          color: Colors.white,
                                                          fontSize:28.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                      Visibility(child: Text(item['subTitle']??'',style: TextStyle(
                                                          fontWeight: FontWeight.w500,
                                                          color: Color.fromRGBO(255, 255, 255, 0.5),
                                                          fontSize:24.sp,
                                                          height: 1.6
                                                      ),maxLines: 1,overflow: TextOverflow.ellipsis,),visible: item['subTitle']!=null&& item['subTitle'].toString().isNotEmpty,)
                                                    ],
                                                  ),
                                                )),
                                                SizedBox(width: 24.w,),
                                                Container(
                                                  constraints: BoxConstraints(
                                                      maxWidth: 230.w
                                                  ),
                                                  child: Text(value,style: TextStyle(
                                                      fontWeight: FontWeight.w400,
                                                      color: Colors.white,
                                                      fontSize: 28.sp
                                                  ),maxLines: 1,overflow: TextOverflow.ellipsis,),
                                                ),
                                                Image.asset('assets/common/control_right.png',width: 48.w,)
                                              ],
                                            ),
                                          ),
                                          // SizedBox(height: 32.w,),
                                          Container(
                                            height: 1.w,
                                            color: Color.fromRGBO(255, 255, 255, 0.1),
                                          )
                                        ],
                                      ),
                                    ),
                                  ));
                                }
                                return Container();
                              },padding: EdgeInsets.zero,itemCount: setItem['isShow']? items.length:0,physics: NeverScrollableScrollPhysics(),shrinkWrap: true,)
                            ],
                          ),
                        ),
                      ],
                    ),
                  );
                },padding: EdgeInsets.zero,itemCount: newSetings.length,),
              ),
            )),
          ],
        ),
      ),
    );
  }

  _changeTime(val){
    String res = '';
    int time = int.parse(val);
    if(time<10){
      res = '0$time''00'; 
    }else{
      res = '$time''00';
    }
    return res;
  }

}
